/**
 * 
 */
package profile.aspect;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.Statement;

/**
 * @author dtran091109
 *
 */
public class SQLExecuteContexts {

	private static ThreadLocal<SQLExecuteContext> contextMap = new ThreadLocal<SQLExecuteContext>() {
		protected SQLExecuteContext initialValue() {
			return new SQLExecuteContext();
		};
	};
	
	public void enableStats(Connection con) {
		try {
			Statement stmt = con.createStatement();
			stmt.execute("set statistics io on");
			//stmt.execute("set showplan on");
			stmt.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void addStatement(Statement stmt, String sql) {
		contextMap.get().addStatement(stmt, sql);
	}

	public void closeStatement(Statement stmt) {
		contextMap.get().closeStatement(stmt);
	}

	
}
